package com.shoppingmall.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 2020/3/14
 * 描述：
 */
public class CommonUtils {

    /**
     * 验证密码是否密码长度6-20位，必须包含数字、字母、符号
     * 至少2种以上元素
     * */
    public static boolean matchPwd(String pwd) {
        String text = "/((?=.*\\d)(?=.*\\D)|(?=.*[a-zA-Z])(?=.*[^a-zA-Z]))(?!^.*[\\u4E00-\\u9FA5].*$)^\\S{6,20}$/";
        Pattern pattern = Pattern.compile(text);
        Matcher matcher = pattern.matcher(pwd);
        if (matcher.find()) {
            return true;
        }
        return false;
    }
}
